package qdu.rg012.srfdraw;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;

import qdu.rg012.draw_view.Viewdraw;

public class Suract extends Activity {
    Mysrfview msrfView;
    Button btngo, btnstop;
    LinearLayout linearLy;

    static boolean flag = false;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initUI();
        btnstop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                flag = false;
            }
        });
        btngo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                flag = true;
            }
        });
    }

    public void initUI(){
        msrfView = new Mysrfview(this);
        linearLy = new LinearLayout(this);
        btngo = new Button(this); btnstop = new Button(this);

        linearLy.addView(btngo); linearLy.addView(btnstop);
        linearLy.addView(msrfView);
        linearLy.setOrientation(LinearLayout.VERTICAL);

        LinearLayout.LayoutParams llpara = (LinearLayout.LayoutParams)btngo.getLayoutParams();
        llpara.width = ViewGroup.LayoutParams.MATCH_PARENT;
        llpara.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        btngo.setLayoutParams(llpara);
        btngo.setText("go");
        llpara = (LinearLayout.LayoutParams)btnstop.getLayoutParams();
        llpara.width = ViewGroup.LayoutParams.MATCH_PARENT;
        llpara.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        btnstop.setLayoutParams(llpara);
        btnstop.setText("stop");

        setContentView(linearLy);
    }
}
